/*
 * Copyright (C) 2012, EADS France
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */
package xowl.gmi.controller;

/**
 *
 * @author Laurent WOUTERS
 */
public class GraphNodeMove extends NodeAction {
    private java.awt.Point oldLocation;
    private java.awt.Point newLocation;
    
    public GraphNodeMove(xowl.interpreter.Repository repository, String parent, String child, java.awt.Point oldLoc, java.awt.Point newLoc) {
        super("Move element", repository, parent, child);
        this.oldLocation = oldLoc;
        this.newLocation = newLoc;
    }
    
    @Override public void execute() { redo(); }
    @Override public void undo() {
        xowl.gmi.model.ast.Decorator decorator = getDecorator();
        decorator.setPositionX(oldLocation.x);
        decorator.setPositionY(oldLocation.y);
    }
    @Override public void redo() {
        xowl.gmi.model.ast.Decorator decorator = getDecorator();
        decorator.setPositionX(newLocation.x);
        decorator.setPositionY(newLocation.y);
    }
}
